<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>

<br>
<div style="text-align: justify;">
    <h3>Vos services en cours</h3><hr>
    <?php
    $rqt_commande = "SELECT idCommande, dateCommande FROM COMMANDE where idUtilisateur=" . $_SESSION['idUtilisateur'];
    $res_commande = mysql_query($rqt_commande);
    while (list($idCommande, $dateCommande) = mysql_fetch_array($res_commande)) {
        //Participation
        $rqt_participation = "SELECT p.idParticipation, m.nomManifestation, m.dateClotureInscription, p.etatParticipation, IFNULL(l.nomLieu,p.AutreLieu) as lieu FROM participation as p LEFT JOIN manifestation as m ON p.idManifestation=m.idManifestation LEFT JOIN Lieu as l ON p.idLieu=l.idLieu WHERE p.idCommande=" . $idCommande;
        $res_participation = mysql_query($rqt_participation);
        while (list($idParticipation, $nomManifestation, $dateClotureInscription, $etatParticipation, $lieu) = mysql_fetch_array($res_participation)) {
            if (time() > $dateClotureInscription) {
                echo '<div class="ligneserviceCATEL" style="height:80px"><center>';
                echo '<table  style="width:93%;text-align:justify;padding-top:3px;"><tr>';
                echo '<td width="65%" style="text-align:justify;vertical-align:middle">';
                echo '<b>' . utf8_encode($nomManifestation) . '</b><br>';
                echo 'Lieu : ' . utf8_encode($lieu) . '<br>';
                echo 'Etat de l\'inscription : ';
                if ($etatParticipation == "PREINSCRIT") {
                    echo "Préinscrit";
                } else {
                    echo "Inscrit";
                }
                echo '<br><a href="#">Commande du ' . strftime("%d/%m/%Y", strtotime($dateCommande)) . '</a>';
                echo '</td>';
                echo '<td width="35%" style="text-align:center;vertical-align:middle">';
                echo '<a href="#" class="bouton1">Modifier ma participation</a>';
                echo '</tr></table>';
                echo '</center></div>';
            }
        }


        //RDV
        $rqt_RDV = "SELECT cr.idCommandeRDV, cr.idRDV, r.intituleRDV, cr.NombreRDV, cr.NombreRDVeffectues FROM commandeRDV as cr LEFT JOIN RDV as r ON cr.idRDV=r.idRDV WHERE idCommande=" . $idCommande;
        //$text_mail.=$rqt_RDV;
        $res_RDV = mysql_query($rqt_RDV);

        while (list($idCommandeRDV, $idRDV, $intituleRDV, $nombreRDV, $nombreRDVeffectues) = mysql_fetch_array($res_RDV)) {
            if ((intval('' . $nombreRDV) > intval('' . $nombreRDVeffectues))) {
                echo '<div class="ligneserviceCATEL" style="height:80px"><center>';
                echo '<table  style="width:93%;text-align:justify;padding-top:3px;"><tr>';
                echo '<td width="65%" style="text-align:justify;vertical-align:middle">';
                echo '<b>' . utf8_encode($intituleRDV) . '</b><br>';
                echo 'Nombre de rendez-vous restants : ' . (intval('' . $nombreRDV) - intval('' . $nombreRDVeffectues)) . '/' . $nombreRDV . '<br>';
                echo '<a href="#">Commande du ' . strftime("%d/%m/%Y", strtotime($dateCommande)) . '</a>';
                echo '</td>';
                echo '<td width="35%" style="text-align:center;vertical-align:middle">';
                echo '<a href="#" class="bouton1">Compléter mes souhaits</a>';
                echo '</tr></table>';
                echo '</center></div>';
            }
        }

        //AccesPlateforme
        $rqt_AP = "SELECT cap.idCommandeAccesPlateforme, cap.idAccesPlateforme, ap.intituleAccesPlateforme, cap.NombreAcces, cap.dateFin FROM commandeAccesPlateforme as cap LEFT JOIN AccesPlateforme as ap ON cap.idAccesPlateforme=ap.idAccesPlateforme WHERE idCommande=" . $idCommande;
        //$text_mail.=$rqt_AP;
        $res_AP = mysql_query($rqt_AP);

        while (list($idCommandeAP, $idAP, $intituleAP, $nombreAP, $dateFin) = mysql_fetch_array($res_AP)) {
            if ($dateFin ==null || $dateFin > time()) {
                echo '<div class="ligneserviceCATEL" style="height:80px"><center>';
                echo '<table  style="width:93%;text-align:justify;padding-top:3px;"><tr>';
                echo '<td width="65%" style="text-align:justify;vertical-align:middle">';               
                echo '<b>' . utf8_encode($intituleAP) . '</b><br>';
                if ($dateFin != null) {
                    $text_mail.= 'Jusqu\'au ' . strftime("%d/%m/%Y", strtotime($datePaiement)).'<br>';
                }
                echo '<a href="#">Commande du ' . strftime("%d/%m/%Y", strtotime($dateCommande)) . '</a>';
                echo '</td>';
                echo '<td width="35%" style="text-align:center;vertical-align:middle">';
                echo '<a href="#" class="bouton1">Accéder à la plateforme</a>';
                echo '</tr></table>';
                echo '</center></div>';
            }
        
        }
    }
    ?>
    <br>
    <h3>Services CATEL</h3><hr>
</div>



<div id="commandeEnCours"></div>
<br><br><br>
<div id="servicesCATEL">

    <div class="ligneserviceCATEL">

        <table width="100%" height="100%">
            <tr>
                <td class="L_cellserviceCATEL"><img width="120px" src="img/services/journee-telesante/2014/visuel-petit.jpg" alt="TELESANTE 2014"/></td>
                <td class="M_cellserviceCATEL">Journée Télésanté 2014</td>
                <td class="R_cellserviceCATEL"><a href="index.php?page=participation_journee" class="bouton1">Inscrivez-vous</a></td>
            </tr>            
        </table>

    </div>    
    <div class="ligneserviceCATEL">

        <table width="100%" height="100%">
            <tr>
                <td class="L_cellserviceCATEL"></td>
                <td class="M_cellserviceCATEL">Rendez-vous individuel spécialisé</td>
                <td class="R_cellserviceCATEL"><a href="#" class="bouton1">Commander</a></td>
            </tr>            
        </table>

    </div>

    <div class="ligneserviceCATEL">

        <table width="100%" height="100%"> 
            <tr>
                <td class="L_cellserviceCATEL"></td>
                <td class="M_cellserviceCATEL">Acces a la Plateforme e-Santé</td>
                <td class="R_cellserviceCATEL"><a href="#" class="bouton1">Commander</a></td>
            </tr>            
        </table>

    </div>


</div>
